package com.yidian.service.impl;

import com.yidian.server.goods.CategoryService;
import com.yidian.server.goods.SkuService;
import org.springframework.beans.factory.InitializingBean;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

/**
 * @author whb
 * @create 2021-06-22 11:00
 * @desciption 实现InitializingBean，系统启动时初始化Bean，会首先调用该接口
 */
@Component
public class Init implements InitializingBean {
    @Autowired
    private CategoryService categoryService;
    @Autowired
    private SkuService skuService;

    @Override
    public void afterPropertiesSet() throws Exception {
        System.out.println("----缓存预热：查询商品分类存入Redis----");
        categoryService.findCategoryTreeToRedis();
        System.out.println("----缓存预热：全部价格存入Redis----");
        skuService.saveAllPriceToRedis();
    }
}
